package com.huike.springboot1.demos.Mapper;

import com.huike.springboot1.demos.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
//    没有加#号的都是数据库中的字段，
//    字段非空且不重复，可以在数据库中设置唯一索引
    @Select("select * from user where username = #{username} and password = #{password}")
    public User signSelect(User user);

//    判断出现次数为多少
    @Select("select count(*) from `user` where username = #{username}")
    public int checkSelect(User user);
    @Insert("insert into user (username, password) values (#{username}, #{password})")
    public void registerInsert(User user);
    @Select("select * from user")
    public List<User> userSelect();//返回的有username,password所以为list类型
    @Delete("delete from user where id = #{id}")
    void deleteUserById(Long id);
}
